language: ruby
os: linux
dist: bionic
addons:
  apt:
    packages:
    - chromium-browser

before_install:
  - bundle config set --local path ../../vendor/bundle without debug

jobs:
  allow_failures:
    - gemfile: spec/gemfiles/rails_main.gemfile
  fast_finish: true
  include:
    - name: Rubocop
      gemfile: spec/gemfiles/rubocop.gemfile
      rvm: 2.7
      script: bundle exec rubocop
      before_install:
      before_script:
      after_script:
      addons:
        apt:
          packages: []
    - name: I18n Tasks
      gemfile: spec/gemfiles/i18n-tasks.gemfile
      rvm: 2.7
      script: bundle exec i18n-tasks health
      before_install:
      before_script:
      after_script:
      addons:
        apt:
          packages: []

    - gemfile: spec/gemfiles/rails_6_0.gemfile
      rvm: 2.7
      before_install: nvm install 14
      env: DB=sqlite3 THREDDED_TESTAPP_SPROCKETS_JS=1
    - gemfile: spec/gemfiles/rails_6_0.gemfile
      rvm: 2.7
      before_install: nvm install 14
      env: DB=postgresql DB_USERNAME=postgres DB_PASSWORD=""
      service: postgresql

    - gemfile: spec/gemfiles/rails_6_1.gemfile
      rvm: 3.0
      before_install: nvm install 14
      env: DB=sqlite3
    - gemfile: spec/gemfiles/rails_6_1.gemfile
      rvm: 2.7
      before_install: nvm install 14
      env: DB=mysql2 DB_USERNAME=root DB_PASSWORD=""
      services: mysql
    - gemfile: spec/gemfiles/rails_6_1.gemfile
      rvm: 2.7
      before_install: nvm install 14
      env: DB=postgresql DB_USERNAME=postgres DB_PASSWORD=""
      services: postgresql

    - gemfile: spec/gemfiles/rails_7_0.gemfile
      rvm: 3.0
      before_install: nvm install 14
      env: DB=postgresql DB_USERNAME=postgres DB_PASSWORD=""
      services: postgresql
    - gemfile: spec/gemfiles/rails_7_0.gemfile
      rvm: 3.0
      before_install: nvm install 14
      env: DB=mysql2 DB_USERNAME=root DB_PASSWORD=""
      services: mysql
    - gemfile: spec/gemfiles/rails_7_0.gemfile
      rvm: 3.0
      before_install: nvm install 14
      env: DB=sqlite3

    - gemfile: spec/gemfiles/rails_main.gemfile
      rvm: 3.0
      before_install: nvm install 14
      env: DB=postgresql DB_USERNAME=postgres DB_PASSWORD=""
      services: postgresql

cache:
  bundler: true
  directories:
  # Cache the Onebox data and views to speed up tests
  - tmp/cache/onebox-data
  - tmp/cache/onebox-views
  - spec/dummy/tmp/cache/onebox-data
  - spec/dummy/tmp/cache/onebox-views

bundler_args: --path ../../vendor/bundle --without debug
env:
  global:
  - COVERAGE=1
  - TRAVIS=1
  - FERRUM_DEFAULT_TIMEOUT=20

before_script:
- >
  if [[ $BUNDLE_GEMFILE != "${PWD}/spec/gemfiles/rails_5_2.gemfile" ]] && [[ -z $THREDDED_TESTAPP_SPROCKETS_JS ]]; then
    cd spec/dummy && yarn && cd -
  fi
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
- chmod +x ./cc-test-reporter
- ./cc-test-reporter before-build
script:
- SIMPLECOV_NAME="test:nojs" bundle exec rspec --force-color --format d --tag=~js --tag=~i18n_tasks
- SIMPLECOV_NAME="test:js" bundle exec rspec --force-color --format d --tag=js
- MIGRATION_SPEC=1 SIMPLECOV_NAME="test:migrations" bundle exec rspec spec/migration --force-color --format d
- spec/configuration/run_all
- bin/run_specs_repeatedly --tag=threaded_render
after_script:
- ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT

notifications:
  slack:
    secure: bnoj7Q/2yA3gtJ2IR/YtXrWCGvN7ukHKnhg1oNYJsOYNk0oEMMgjmGnIRrcdxO4peyOid6aKlcMmP7zrOzPEJsN3qAA4UUCRGq0TgZ2RDMX1sRZ8NN/xCyt84WU9aEtTF0V1hUyG/OaQ7G65XN/XuwJGzw6VDSZE54FSdR/5/eQ=
